<!--
 * @Description: 发起项目
 * @Author 卞鹏飞 <228443632@qq.com>
 * @create 03/09/24 PM5:22
 -->
<!--setup-->
<script setup>
import { onMounted, getCurrentInstance, ref } from 'vue'
import { BaseFormItem, BaseForm } from '@shared/base/base-form'
import prjInfoApi from '@/api/modules/prj-info' // api接口
import { to } from 'sf-utils2'
import { ElMessage } from 'element-plus'

const { proxy } = getCurrentInstance()
const props = defineProps({})
const emit = defineEmits([])

/* 状态 */
const formData = ref({})
const baseFormRef = ref() // base-form 实例

/* 方法 */
/**
 * 提交
 */
const onSubmit = async () => {
  const valid = await baseFormRef.value.validate()
  if (valid) {
    const [res, err] = await to(prjInfoApi.createPrjInfo(formData.value))
    if (err || res?.code !== 200) {
      ElMessage.error(res?.message || String(err))
      return false
    }
    return res
  }
}

/* 计算 */

/* 监听 */

/* 周期 */
onMounted(() => {})

/* 暴露 */
defineExpose({
  $: proxy.$,
  onSubmit
})
</script>

<!--render-->
<template>
  <BaseForm
    ref="baseFormRef"
    v-model="formData"
    label-position="top"
  >
    <BaseFormItem
      label="项目名称"
      prop="prjName"
      type="input"
      required
      maxlength="200"
      :component-attrs="{ showWordLimit: false }"
      :col="24"
      placeholder="请输入"
    />
    <BaseFormItem
      label="出让方"
      prop="transferor"
      type="input"
      required
      maxlength="200"
      :component-attrs="{ showWordLimit: false }"
      :col="24"
      placeholder="请输入"
    />
    <BaseFormItem
      label="项目类型"
      prop="prjType"
      type="select"
      dict="projectType"
      required
      :col="24"
      placeholder="请选择"
    />
    <BaseFormItem
      label="资产类型"
      prop="assetType"
      type="text"
      required
      maxlength="200"
      :component-attrs="{ showWordLimit: false }"
      :col="24"
      placeholder="请输入"
    />
    <BaseFormItem
      label="收购方式"
      prop="acqstnType"
      type="select"
      dict="purchaseType"
      required
      :col="24"
      placeholder="请选择"
    />
  </BaseForm>
</template>

<!--style-->
<style scoped lang="less"></style>
